<template>
    <h2>排房列表</h2>
    <table>
      <tr>
        <td>房号</td>
        <td>排房时间</td>
        <td>房态</td>
        <td>图片</td>
        <td>操作</td>
      </tr>
      <tr v-for="item in list">
        <td>{{item.nname}}</td>
        <td>{{item.ptime.substr(0,10)}}</td>
        <td>{{item.statename}}</td>
        <td><img :src="'https://localhost:7214'+item.picture" width="60" height="60"></td>
        <td><input type="button" value="删除" @click="delconii(item.hid)"></td>
      </tr>
    </table>
  </template>
  
  <script setup lang="ts">
  import {onMounted, reactive, toRefs} from 'vue'
  import {useRouter,useRoute} from 'vue-router'
  import axios from 'axios'
  const router=useRouter()
  const route=useRoute()

  let data:any=reactive({
    list:[],
    priso:{
      index:1,
      page:2
    },
    count:0,
    pcount:0
  })
  let {list,priso,count,pcount} =toRefs(data)

  onMounted(()=>{
    getlistooo()
  })

  const getlistooo=()=>{
    let obj={
      index:priso.value.index,
      page:priso.value.page
    }
    axios({
      url:'/api/Room/Getpaifang',
      method:'get',
      params:obj
    })
    .then(res=>{
      list.value=res.data.data;
      count=res.data.coco;
      pcount=res.data.promax;
    })
  }

  const delconii=(hid:any)=>{
    if(confirm("确认删除吗？")){
      let obj={
      hid:hid
    }
    axios({
      url:'/api/Room/Delrows',
      method:'get',
      params:obj
    })
    .then(res=>{
      if(res.data.data==1){
        alert("删除成功")
        getlistooo()
      }else{
        alert("删除失败")
      }
    })
    }
    
  }
  </script>
  
  <style scoped>
  
  </style>